home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / windows / winxs16.zip / CAT-S.SED next >
Text File  |  1995-11-21  |  490b  |  32 lines

  1. #n
  2.  
  3. # sed script to simulate the BSD cat -s command,
  4. # squeezing excess blank lines from the input.
  5.  
  6. # write non-empty lines
  7.  
  8. /./{
  9.     p
  10.     d
  11. }
  12.  
  13. # Write a single empty line.
  14.  
  15. /^$/p
  16.  
  17. # Get next line, discard the <newline> character
  18. # inserted by the 'N' command, then check for more
  19. # adjacent empty lines.
  20.  
  21. :Empty
  22. /^$/{
  23.     N
  24.     s/.//
  25.     b Empty
  26. }
  27.  
  28. # Write the non-empty line read by 'N' above, and
  29. # restart the search for the next set of empty lines.
  30.  
  31. p
  32.